home *** CD-ROM | disk | FTP | other *** search
/ Interactive Web Graphics with Shout 3D / Interactive Web Graphics With Shout 3D.iso / pc / Shout3Ddemo / Shout3d_runtime / codebase / custom_nodes / SimpleInline.java < prev    next >
Text File  |  2000-09-21  |  1KB  |  59 lines

  1. /**    
  2.     Company:        Eyematic Interfaces
  3.     Project:        Shout3D 2.0 Sample Code
  4.     Class:            Inline
  5.     Date:            September 21, 2000
  6.     Description:    Simple VRML style Inline node.
  7.     (C) Copyright Eyematic Interfaces, Inc. - 1997-2000 - All rights reserved
  8.  */
  9.  
  10. package custom_nodes;
  11.  
  12. import  shout3d.core.*;
  13.  
  14. /**
  15.  * SimpleInline.
  16.  * 
  17.  * @author Paul Isaacs
  18.  */
  19.  
  20. public class SimpleInline extends Transform implements FieldObserver {
  21.     
  22.     /**
  23.      * url field.  This should be a string denoting a path to the .s3d file, relative to 
  24.      * the codebase directory.
  25.      */
  26.     final public    StringArrayField    url  = new StringArrayField(this, "url",  Field.ANY, null);
  27.     
  28.     /**
  29.      * Constructs a default SimpleInline
  30.      */
  31.     public SimpleInline(){
  32.         url.addFieldObserver(this, null);
  33.     }
  34.     
  35.     protected void finalize() throws Throwable { 
  36.         url.removeFieldObserver(this);
  37.         super.finalize();
  38.     }
  39.     
  40.     /**
  41.      * 
  42.      * Subclasses must call this from within their own onFieldChange() method.
  43.      * 
  44.      */
  45.     public void onFieldChange(Field theField, Object userData) {
  46.         if ( theField == url ){
  47.             // can't load a scene unless you've got a viewer.
  48.             if (getViewer() != null ){
  49.                 getViewer().loadURL(url.getValue(), this);
  50.             }
  51.         }
  52.         else {
  53.             // Call the super class, it's not a field this node cares about.
  54.             super.onFieldChange(theField, userData);
  55.         }
  56.     }
  57.     
  58. }
  59.